home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 7 / BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso / Files / Game / R / ROBOT WARRIORS 1.0.1.CPT / Robot Warriors / Example Robots / Wall Crawler < prev   
Text File  |  1991-08-26  |  2KB  |  66 lines

  1. ;  Robot Name:  Rambo Wall Crawler
  2. ;
  3. ;  Crawl around the outside wall looking for robots to shoot while trying
  4. ;  to avoid colliding with other robots.
  5.  
  6.  
  7. ; Rambo Wall Crawler is tough and fast but can't see very far.
  8. ARMOR 2
  9. FIRE_RATE 1
  10. FUEL_CAPACITY 2
  11. ENGINE_SIZE 1
  12.  
  13. define safety_dist 29   ;Distance away from the wall when it's time to turn
  14. define collide_dist 50  ;If we see a robot in our path this far away, turn
  15. define delta -90        ;This defines our direction of travel
  16. allocate count
  17.  
  18.     40 to speed
  19.     0 to direction
  20.     0 to count
  21. again
  22.      ; Check for a wall and turn if too close to one
  23.      ; This robot only moves up, down, left, or right. This makes
  24.      ; it easy to check one of four walls depending on direction.
  25.     if direction = 0 then gosub dir0
  26.     if direction = 90 then gosub dir90
  27.     if direction = 180 then gosub dir180
  28.     if direction = 270 then gosub dir270
  29.     
  30.      ; every so often look in front to check for collision
  31.     count + 1 to count
  32.     if count = 5 then
  33.         direction to radar
  34.         if radar >= 0 then
  35.             if radar < collide_dist then
  36.                  direction + delta to direction  ; avoid collision
  37.                  0 to count
  38.             end
  39.         end
  40.     end
  41.  
  42.     aim + 10 to aim to radar    ;Scan for a robot
  43.     if radar > 0 then radar to shot
  44.  
  45.     if speed = 0 then
  46.         direction + delta to direction
  47.         40 to speed
  48.     end
  49. goto again
  50.     
  51. dir0        ;Check for hitting the top wall
  52.     if y < safety_dist then direction + delta to direction
  53.     return
  54.  
  55. dir90       ;Check for hitting the right wall
  56.     if x+safety_dist > XMAX then direction + delta to direction
  57.     return
  58.  
  59. dir180      ;Check for hitting the bottom wall
  60.     if y+safety_dist > YMAX then direction + delta to direction
  61.     return
  62.  
  63. dir270      ;Check for hitting the left wall
  64.     if x < safety_dist then direction + delta to direction
  65.     return
  66.